#!/bin/bash

echo "启动Model Evaluator后端服务..."

# 检查是否在正确的目录
if [ ! -f "backend/main.py" ]; then
    echo "错误：请在项目根目录运行此脚本"
    exit 1
fi

# 检查Python环境
if ! command -v python &> /dev/null; then
    echo "错误：未找到Python，请确保已安装Python"
    exit 1
fi

# 检查依赖是否已安装
if ! python -c "import fastapi" &> /dev/null; then
    echo "安装Python依赖..."
    pip install -r requirements.txt
fi

# 检查环境变量
if [ -z "$DASHSCOPE_API_KEY" ]; then
    echo "警告: DASHSCOPE_API_KEY 环境变量未设置"
    echo "请设置环境变量: export DASHSCOPE_API_KEY='your-api-key'"
    echo "或者创建 .env 文件并设置API Key"
fi

# 启动后端服务
echo "启动后端服务在 http://localhost:8000"
cd backend
python main.py 